package com.kevinxiaoge.ruoli.demo;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author chengyuanyuan
 */
public class CASDemo {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(2010);

        System.out.println(atomicInteger.compareAndSet(2010, 2011));
        System.out.println(atomicInteger.get());

        System.out.println(atomicInteger.compareAndSet(2011, 2010));
        System.out.println(atomicInteger.get());

        System.out.println(atomicInteger.compareAndSet(2010, 2011));
        System.out.println(atomicInteger.get());
    }
}
